package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0155.java
 * @Author : WangRuoyu
 * @Date 2023/11/16 21:16
 */

public class Q0155 {
    int[] s1 = new int[(int) (3 * 1e4) + 10];
    int[] s2 = new int[(int) (3 * 1e4) + 10];
    int count = 0;

    public Q0155() {
//    public MinStack() {

    }

    private boolean isEmpty() {
        return count == 0;
    }

    public void push(int val) {
        s1[count] = val;
        if (isEmpty()) {
            s2[count++] = val;
        } else {
            s2[count] = Math.min(s2[count - 1], s1[count]);
            count++;
        }
    }

    public void pop() {
        if (isEmpty()) return;
        count--;
    }

    public int top() {
        return s1[count - 1];
    }

    public int getMin() {
        return s2[count - 1];
    }
}